<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../lib/layui/css/layui.css" />
		<script type="text/javascript" src="../js/global.js" ></script>
		<script type="text/javascript" src="../lib/layui/layui.js" ></script>
		<link rel="stylesheet" href="../css/xadmin.css" media="all">
	</head>
	<body>
		<div class="x-nav">
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
		<table id="tab3" lay-filter="table3">
		</div>	
			<!--详情-->
			<div id="Div" style="display: none;" style="width:400px;height:250px;">
			<form id="Xq" style="margin-top:20px;" class="layui-form"  method="post" onsubmit="return false;">
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪人员：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input class="layui-input" disabled id="as" lay-verify="required|vname" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">客户：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input class="layui-input" disabled id="stu"  />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪时间：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input class="layui-input" disabled id="followtime"  />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪类型：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input class="layui-input" disabled id="followtype"  />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪状态：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input class="layui-input" id="followstate" disabled  />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪内容：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<textarea class="layui-textarea" id="content" disabled ></textarea>
					</div>
				</div>
			</form>
		</div>
			<!--编辑-->
			<div id="add" style="display: none;" style="width:400px;height:250px;">
			<form id="formAddRole" style="margin-top:20px;" class="layui-form"  method="post" onsubmit="return false;">
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪类型：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input class="layui-input" id="followtype1" name="followtype" lay-verify="required|vname" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪状态：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<input hidden="hidden" id="id" name="id">
						<input class="layui-input" id="followstate1" name="followstate" lay-verify="required|vname" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-mid">跟踪内容：</label>
					<div class="layui-input-inline" style="width: 350px;">
						<textarea class="layui-textarea" id="content1" name="content" lay-verify="required|vname"></textarea>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit="" lay-filter="upAll"><i class="layui-icon">&#xe605;</i>保存</button>
						<button type="reset" class="layui-btn layui-btn-primary"><i class="layui-icon">&#x1006;</i>重置</button>
					</div>
				</div>
			</form>
		</div>
			
			
			<script type="text/html" id="low">
				<!--<button class="layui-btn  layui-btn-lg layui-btn-danger" lay-event="delenet">删除</button>-->
				<button class="layui-btn  layui-btn-sm layui-btn-normal" lay-event="upnet">编辑</button>
			</script>
		</table>
		
	</body>
	    <script>
			layui.use(['layer','table','form','laydate'],function(){
				var layer=layui.layer;
				var table=layui.table;
				var form=layui.form;
				var $ =layui.$;
				var laydate = layui.laydate;
				
				var sid=getQueryVariable("stuid");//获取url里的参数id
				table.render({
					elem:"#tab3",
					method:"post",
					url:"http://localhost:8080/Net/getAllNetFollow",
					where:{
						'token': globalData.getCurToken(),
						"stuid":sid
					},
					page:true,
					parseData: function(res) {
					return {
						"code": 0,
						"msg": "1",
						"count": res.totalElements,
						"data": res.content
					}
				},
					cols:[[{
						templet:'<div>{{d.student.name}}</div>',
						title:"客户姓名"
					},
					{
						field:"",
						templet:"<div>{{d.asker.askername}}</div>",
						title:"跟踪咨询师"
					},
					{
						field:"followtime",
						title:"跟踪时间"
					},
					{
						field:"createtime",
						title:"创建时间"
					},
					{
						field:"followtype",
						title:"跟踪类型"
					},
					{
						field:"cz",
						title:"操作",
						templet: "#low",
					}
					]],id:"bb"
				})
			
			table.on("tool(table3)",function(obj){
				var event=obj.event;
				var data=obj.data;
				var id=data.id;
				if(event=="upnet"){
					$("#id").val(data.id)
					$("#followstate1").val(data.followstate);
					$("#content1").val(data.content);
					$("#followtype1").val(data.followtype);
					layer.open({
						type:1,
						content:$("#add"),
						title:"正在修改",
						area:["450px","500px"]
					})
					
				}
				
			})
				form.on("submit(upAll)",function(asd){
					var saa=$("#formAddRole").serialize()+"&token="+globalData.getCurToken();
					$.post("http://localhost:8080/Net/UPdate",saa,function(qq){
						if(qq>0){
							layer.msg("修改成功",{
								icon:1,
								time:2000
							},function(){
								location.reload();
							})
							
						}else if(res.code=-1){
							layer.msg(res.msg);
						}else{
							layer.msg("修改失败",{
								icon:1,
								time:2000
							})
						}
					})
				})
				//监听行单击事件（双击事件为：rowDouble）
			  table.on('rowDouble(table3)', function(obj){
			    var data=obj.data;
			  $("#as").val(data.asker.askername);
			  $("#stu").val(data.student.name);
			  $("#followtime").val(data.followtime);
					$("#followstate").val(data.followstate);
					$("#content").val(data.content);
					$("#followtype").val(data.followtype);
						layer.open({
							type: 1,
							title: '详情信息',
							content: $("#Div"),
							area: ['550px', '500px']
						})
			    
			    //标注选中样式
			    obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
			  });
				
				/*获取url参数*/
	function getQueryVariable(variable){
       	var query = window.location.search.substring(1);
       	var vars = query.split("&");
       	for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
       	}
       return(null);
	}
				
			})
			
		</script>
</html>
